package com.yc.tomcat.impl;

import com.yc.tomcat.HttpServletRequest;
import com.yc.tomcat.HttpServletResponse;
import com.yc.tomcat.ServletException;

import javax.servlet.annotation.WebServlet;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/hello.s")
public class HelloServlet extends HttpServletImpl{

    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
        PrintWriter out = response.getWriter();
        response.setContentType("text/html;charset=utf-8");

        String name = request.getParameter("name");
        if(name == null){
            name = "world";
        }

        out.println("hello " + name + "!");
    }
}
